package util.ComplexTable;

import banco.ConexaoBD;
import banco.UsuarioDAO;
import beans.Professor;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ViewScoped
@ManagedBean(name = "tableBean")
@SessionScoped
public class TableBean implements Serializable {
  
    private Professor selectedProfessor;
    private List<Professor> professores;
    private Professor[] vetorProfessores;

    UsuarioDAO banco = new UsuarioDAO(ConexaoBD.getConexaoBD());

    public TableBean() throws SQLException {

        vetorProfessores = banco.getObjProfessor();

        professores = new ArrayList<Professor>();

        System.out.println("Tamanho " + vetorProfessores[0]);

        for (int i = 1; i < vetorProfessores.length; i++) {
            professores.add(vetorProfessores[i]);
            //vetorProfessores[i].
        }
    }

    public Professor getSelectedProfessor() {
        return selectedProfessor;
    }

    public void setSelectedProfessor(Professor selectedProfessor) {
        this.selectedProfessor = selectedProfessor;
    }

    public String teste (Professor selecionado){

        Professor tst = new Professor();

        System.out.println("Nome selecionado" + selecionado.getNome());
        tst.setNome(selecionado.getNome());

        return "previsualizarCadastroProfessor.xhtml";
    }

    public List<Professor> getProfessores() {
        return professores;
    }
}
